import {createRouter ,createWebHashHistory} from "vue-router";
import store from "../store/index";
const router =createRouter({
    history:createWebHashHistory(),
    routes:[
        {
            path:"/",
            component:()=> import('../components/First.vue')
        },
        {
            path:"/sec",
            component:()=> import('../components/Sec.vue')
        
        },
        {
            path:"/ITEM",
            component:()=> import('../components/ITEMmusic.vue')
        
        },
        {
            path:"/Search",
            component:()=> import('../components/Search.vue')
        
        },
          {
            path:"/Login",
            component:()=> import('../components/Login.vue')
        
        },
        {
            path:"/We",
            component:()=> import('../components/We.vue')
        },
        {
            path:"/InfoUser",
            beforeEnter:(to,from,next)=>{
                if(store.state.isLogin  ||store.state.token ||localStorage.getItem('token')){
                    next()
                }else{
                    next('/login')
                }
            },
            component:()=> import('../components/InfoUser.vue')
        
        }
    ]
})
router.beforeEach((to,from)=>{
  if(to.path=='/Login'){
    store.state.isFooterMusic=false
  }else{
    store.state.isFooterMusic=true
  }
})
export default router